package schema

import (
	"entgo.io/ent"
	"entgo.io/ent/dialect/entsql"
	"entgo.io/ent/schema"
	"entgo.io/ent/schema/field"
	"entgo.io/ent/schema/index"
	"private-domain-overseas-service/pkg/status/bizadmin"
	"time"
)

type AdminLog struct {
	ent.Schema
}

// Fields of the AdminLog.
func (AdminLog) Fields() []ent.Field {
	return []ent.Field{
		field.String("admin_log_account").Optional().Comment("用户账号"),
		field.String("admin_log_ip").Optional().Comment("所在ip"),
		field.String("admin_log_url").Optional().Comment("访问url"),
		field.String("admin_log_page").Optional().Comment("访问页面名称"),
		field.String("admin_log_operate_system").Optional().Comment("操作系统"),
		field.String("admin_log_browser").Optional().Comment("浏览器json信息"),
		field.String("admin_log_extra_info").MaxLen(5000).Optional().Comment("额外信息"),
		field.Int64("is_delete").Default(bizadmin.NotDelete).Comment("是否删除,1、未删除,2、表示删除"),
		field.Time("create_at").Immutable().Default(time.Now).Comment("创建时间"),
		field.Time("update_at").Default(time.Now).Comment("更新时间"),
		field.Time("delete_at").Optional().Comment("删除时间"),
	}
}

// Indexes of the Street.
func (AdminLog) Indexes() []ent.Index {
	return []ent.Index{
		index.Fields("admin_log_account"),
		index.Fields("admin_log_ip"),
	}
}

func (AdminLog) Annotations() []schema.Annotation {
	return []schema.Annotation{
		entsql.WithComments(true),
		schema.Comment("后台日志表"),
	}
}
